package com.jijuxie.agent.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jijuxie.agent.domain.Agent;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface AgentMapper extends BaseMapper<Agent> {

    /**
     * 通过用户ID查询经纪人信息（最新一条记录）
     */
    Agent selectAgentByUserId(@Param("userId") Long userId);
    
    /**
     * 自定义分页查询经纪人列表，完整查询所有字段
     */
    @Select("SELECT agent_id, user_id, real_name, id_card, agent_no, company, position, " +
           "work_years, avatar, status, del_flag, create_time, update_time, remark, " +
           "title, rating, deals, service_area, introduction, expertise, license_no, " + 
           "license_image, auditor_id, audit_time, audit_remark " +
           "FROM agent_info ${ew.customSqlSegment}")
    Page<Agent> selectAgentPageCustom(Page<Agent> page, @Param("ew") com.baomidou.mybatisplus.core.conditions.Wrapper<Agent> queryWrapper);
}
